#pragma once
#include <cstdint>

class EventLoop;

/// 所有具体 fd 处理对象的抽象基类
class EventHandler {
public:
    EventHandler(EventLoop& loop, int fd);
    virtual ~EventHandler();

    int fd() const { return fd_; }
    EventLoop& loop() { return loop_; }

    /// 由 EventLoop 在对应线程内调用
    virtual void handleEvent(uint32_t events) = 0;

protected:
    void closeFd();

private:
    EventLoop& loop_;
    int fd_;
};